package com.css.fxfzaqbz.modules.data.controller;

import com.css.fxfzaqbz.base.response.RestResponse;
import com.css.fxfzaqbz.modules.data.queryParams.DisposeVo;
import com.css.fxfzaqbz.modules.data.queryParams.SeismicHazardAssessQueryParams;
import com.css.fxfzaqbz.modules.data.service.SeismicHazardAssessService;
import com.css.fxfzaqbz.modules.data.vo.BigStatusVo;
import com.css.fxfzaqbz.util.CodeUtil;
import com.css.fxfzaqbz.util.PlatformPageUtils;
import com.css.fxfzaqbz.zcpt.sys.service.SysAreaService;
import com.css.fxfzaqbz.zcpt.sys.service.impl.SUserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * 地震灾害风险等级量化评估
 */
@RestController
@RequestMapping("/fxfzaqbz/data")
@Slf4j
public class SeismicHazardAssessController {

    @Resource
    SeismicHazardAssessService seismicHazardAssessService;

    @Resource
    private SysAreaService sysAreaService;
    @Resource
    private SUserServiceImpl sUserServiceImpl;


    /**
     * 查询
     *
     * @param request
     * @param queryParams
     * @return
     */
    @GetMapping("/getAllSeismicHazardAssess")
    public RestResponse getAllSeismicHazardAssess(HttpServletRequest request, SeismicHazardAssessQueryParams queryParams) {

        RestResponse restResponse = null;
        try {
            int curPage = Integer.valueOf(request.getParameter(PlatformPageUtils.CUR_PAGE));
            int pageSize = Integer.valueOf(request.getParameter(PlatformPageUtils.PAGE_SIZE));
            queryParams.setCurPage(curPage);
            queryParams.setPageSize(pageSize*6);
            Map<String, Object> allSeismicHazardAssess = seismicHazardAssessService.getAllSeismicHazardAssess(queryParams);
            if (allSeismicHazardAssess==null){
                restResponse = RestResponse.fail("完善个人地址信息后查看");
            }else {
                restResponse = RestResponse.succeed(allSeismicHazardAssess);
            }

        } catch (Exception e) {
            log.error("查询地震风险等级量化评估数据失败", e);
            restResponse = RestResponse.fail("查询地震风险等级量化评估数据失败");
        }
        return restResponse;
    }

    //进入的时候修改状态
    @PostMapping("/updateBigStatus")
    public RestResponse updateBigStatus(@RequestBody BigStatusVo bigStatusVo) {
        RestResponse restResponse = null;
        try {
            seismicHazardAssessService.updateBigStatus(bigStatusVo);
            restResponse = RestResponse.succeed();
        } catch (Exception e) {
            log.error("处理失败", e);
            restResponse = RestResponse.fail("处理失败!");
        }
        return restResponse;
    }



}